//
//  KDDayCardController.m
//  KongDays
//
//  Created by deeplu on 12. 12. 21..
//  Copyright (c) 2012년 BlueBeans. All rights reserved.
//

#import "KDDayCardController.h"
#import "KDAppDelegate.h"
#import "NSDay.h"
#import <QuartzCore/QuartzCore.h>

@interface KDDayCardController ()

- (void)close;

@end

@implementation KDDayCardController
@synthesize day = day_;
@synthesize actualView;
@synthesize titleLabel;
@synthesize closeButton;

- (id)init
{
    self = [super initWithNibName:@"KDDayCardController" bundle:nil];
    if (self) {

        UIColor *backgroundColor =
            [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
        
        self.view.backgroundColor = backgroundColor;

    }
    
    return self;
}

- (void)dealloc
{
    [self.actualView release];
    [self.day release];
    [self.titleLabel release];
    [self.closeButton release];
    
    [super dealloc];
}

#pragma mark - UIViewController methods

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    if (self.day) {
        self.titleLabel.text = self.day.title;
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

#pragma mark IBAction methods

- (IBAction)close:(id)sender
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(close)];
    
    self.view.alpha = 0.0;
    
    [UIView commitAnimations];
}

#pragma mark - Private methods

- (void)close
{
    [self.view removeFromSuperview];
}

@end
